package org.zjx.model.route;

import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.zjx.entity.Location;
import org.zjx.enums.route.RouteType;

/**
 * 场景传送路由类
 * 表示场景间传送的路径(单向)
 */

@JSONType(typeName = "SceneTransferRoute")
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class SceneTransferRoute extends AbstractRoute {
    private int clickX;  // 需要点击的X坐标
    private int clickY;  // 需要点击的Y坐标

    /**
     * 构造函数
     *
     * @param start  起点
     * @param end    终点
     * @param clickX 点击X坐标
     * @param clickY 点击Y坐标
     */
    public SceneTransferRoute(Location start, Location end, int clickX, int clickY) {
        super(start, end, 3, RouteType.SCENE_TRANSFER, false);
        if (start.sameScene(end)) {
            throw new IllegalArgumentException("场景传送必须跨场景");
        }
        this.clickX = clickX;
        this.clickY = clickY;
    }

    /**
     * 创建反向路由(不支持)
     *
     * @throws UnsupportedOperationException 总是抛出
     */
    @Override
    protected Route createReverseRoute() {
        throw new UnsupportedOperationException("Scene transfer is unidirectional");
    }

    /**
     * 获取路由描述
     *
     * @return 描述字符串
     */
    @Override
    public String getDescription() {
        return String.format("从%s传送到%s，点击位置[%d,%d]，耗时%d秒",
                getStart(), getEnd(), clickX, clickY, getTime());
    }
}